package com.supergdtop.www.run.activity.designer;

import android.content.Intent;

import android.content.res.ColorStateList;
import android.graphics.Color;
import android.support.v4.widget.DrawerLayout;


import android.text.InputType;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TableLayout;
import android.widget.TextView;

import com.asum.xlayoutparams.utils.XPxArea;
import com.asum.xuidesign.utils.view.TextViewTools;
import com.supergdtop.www.run.R;
import com.supergdtop.www.run.finaldata.FontSize;
import com.supergdtop.www.run.finaldata.XColor;
import com.supergdtop.www.run.tools.TextTools;
import com.supergdtop.www.run.view.CircleImageView;


/**
 * 主界面包含drawlayoutdesign
 * Created by chn10 on 2016/10/19.
 */

public class MainActivityDesigner extends ActivityDesigner {

    public DrawerLayout drawerLayout;
    private LinearLayout contentlayout;
    private LinearLayout listlayout;

    private LinearLayout above;
    private LinearLayout headlayout;
    private CircleImageView headimageView;

    private TextView usernameTextView;

    private LinearLayout detailinfolayout;
    private LinearLayout daylayout;
    private TextView daytext;
    private TextView daynum;

    private View view;

    private LinearLayout focoulayout;
    private TextView focousText;
    private TextView focousnum;

    public TextView mytipsTextview;
    public TextView sportmonitorTextView;
    public TextView userifoTextView;
    public TextView securitycenterTextView;

    private LinearLayout userinfo;
    private TextView usetext;
    public EditText userinput;

    private LinearLayout userpwdinfo;
    private TextView pwdtext;
    public EditText pwdinput;

    public Button loginbutton;
    public Button registerbutton;




    protected void design(Intent intent) {
    }

    protected void getWidgets() {
        drawerLayout = designer.getViewById(R.id.drawer_layout);
        contentlayout = designer.getViewById(R.id.contenview);
        listlayout = designer.getViewById(R.id.rightcontentlayout);

        above = designer.getViewById(R.id.abovelayout);
        headlayout = designer.getViewById(R.id.headlyout);

        headimageView = designer.getViewById(R.id.headimage);
        usernameTextView = new TextView(context);

        detailinfolayout = new LinearLayout(context);
        daylayout = new LinearLayout(context);
        daytext = new TextView(context);
        daynum = new TextView(context);

        view = new View(context);

        focoulayout = new LinearLayout(context);
        focousText = new TextView(context);
        focousnum = new TextView(context);

        mytipsTextview = new TextView(context);
        sportmonitorTextView = new TextView(context);
        userifoTextView = new TextView(context);
        securitycenterTextView = new TextView(context);

        userinfo = new LinearLayout(context);
        usetext = new TextView(context);
        userinput = new EditText(context);

        userpwdinfo = new LinearLayout(context);
        pwdtext = new TextView(context);
        pwdinput = new EditText(context);

        loginbutton = new Button(context);
        registerbutton = new Button(context);




    }

    protected void setWidgets() {

        contentlayout.setBackgroundColor(XColor.WHITE);
        contentlayout.setOrientation(LinearLayout.VERTICAL);
        contentlayout.setPadding(padding,padding,padding,padding);
        contentlayout.setGravity(Gravity.CENTER_HORIZONTAL);
        new XPxArea(contentlayout).set(0, 0, XPxArea.MATCH,XPxArea.MATCH);

        contentlayout.addView(userinfo);
        userinfo.setPadding(padding,0,padding,0);
        userinfo.setOrientation(LinearLayout.HORIZONTAL);
        new XPxArea(userinfo).set(0,0,XPxArea.MATCH,XPxArea.WRAP);

//        userinfo.addView(usetext);
//        usetext.setText("用户名：");
//        usetext.setBackgroundColor(XColor.BLUE);
//        usetext.setTextSize(TypedValue.COMPLEX_UNIT_PX, FontSize.s21(context));
//        new XPxArea(usetext).set(padding,0,XPxArea.WRAP,XPxArea.WRAP);

//        userinfo.addView(userinput);
//        userinput.setBackground(null);
//        //userinput.setBackgroundColor(XColor.BLUE);
//        new XPxArea(userinput).set(0,0,screenW*0.6,XPxArea.WRAP);
//
//        contentlayout.addView(userpwdinfo);
//        userpwdinfo.setPadding(padding,0,padding,0);
//        userpwdinfo.setOrientation(LinearLayout.HORIZONTAL);
//        new XPxArea(userpwdinfo).set(0,0,XPxArea.MATCH,XPxArea.WRAP);
//
//        userpwdinfo.addView(pwdtext);
//        pwdtext.setText("密码栏：");
//        //usetext.setBackgroundColor(XColor.BLUE);
//        pwdtext.setTextSize(TypedValue.COMPLEX_UNIT_PX, FontSize.s21(context));
//        new XPxArea(pwdtext).set(padding,0,XPxArea.WRAP,XPxArea.WRAP);
//
//        userpwdinfo.addView(pwdinput);
//        pwdinput.setBackground(null);
//        pwdinput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
//        //userinput.setBackgroundColor(XColor.BLUE);
//        new XPxArea(pwdinput).set(0,0,screenW*0.6,XPxArea.WRAP);
//
//        contentlayout.addView(loginbutton);
//        loginbutton.setText("Login");
//        loginbutton.setBackgroundColor(XColor.GRAY);
//        new XPxArea(loginbutton).set(0,padding*2,XPxArea.MATCH,XPxArea.WRAP);
//
//        contentlayout.addView(registerbutton);
//        registerbutton.setText("Register");
//        registerbutton.setBackgroundColor(XColor.GRAY);
//        new XPxArea(registerbutton).set(0,padding*2,XPxArea.MATCH,XPxArea.WRAP);

        //————————————————————菜单栏布局——————————————————————
        listlayout.setBackgroundColor(Color.rgb(30,30,30));

        listlayout.setOrientation(LinearLayout.VERTICAL);

        //above.setBackgroundColor(XColor.RED);
        above.setOrientation(LinearLayout.VERTICAL);
        above.setGravity(Gravity.CENTER_HORIZONTAL);
        new XPxArea(above).set(0,padding,XPxArea.MATCH,screenW*0.7);

        headlayout.setGravity(Gravity.CENTER_VERTICAL);
        //headlayout.setBackgroundColor(XColor.BLUE);
        headlayout.setGravity(Gravity.CENTER_HORIZONTAL);
        new XPxArea(headlayout).set(0,padding*2,XPxArea.MATCH,XPxArea.WRAP);

        headimageView.setBorderColor(Color.rgb(55,55,55));
        headimageView.setBorderWidth(padding);
        new XPxArea(headimageView).set(0,0,screenW*0.33,screenW*0.33);

        above.addView(usernameTextView);
        usernameTextView.setText("Dc.Lemon");

        new TextViewTools(usernameTextView).textColor(XColor.WHITE).sizePx(FontSize.s21(context));
        new XPxArea(usernameTextView).set(0,padding*2,XPxArea.WRAP,XPxArea.WRAP);
        // 运动天数关注量
        above.addView(detailinfolayout);
        detailinfolayout.setOrientation(LinearLayout.HORIZONTAL);
        //detailinfolayout.setBackgroundColor(XColor.GREEN);
        detailinfolayout.setGravity(Gravity.CENTER_HORIZONTAL);
        detailinfolayout.setPadding(padding,padding,padding,padding);
        new XPxArea(detailinfolayout).set(0,padding,XPxArea.MATCH,screenH*0.1);

        detailinfolayout.addView(daylayout);
        daylayout.setOrientation(LinearLayout.VERTICAL);
        //daylayout.setBackgroundColor(XColor.RED);
        daylayout.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
        new XPxArea(daylayout).set(0,0,screenW*0.24,XPxArea.MATCH);

        daylayout.addView(daynum);
        daynum.setText("20154");
        new XPxArea(daynum).set(padding/4,0,XPxArea.WRAP,XPxArea.WRAP);
        new TextViewTools(daynum).textColor(XColor.WHITE);

        daylayout.addView(daytext);
        daytext.setText("累计运动天数");
        new XPxArea(daytext).set(0,0,XPxArea.WRAP,XPxArea.WRAP);
        new TextViewTools(daytext).textColor(XColor.WHITE);

        detailinfolayout.addView(view);
        view.setBackgroundColor(XColor.WHITE);
        new XPxArea(view).set(padding*2,0,space,XPxArea.MATCH);

        detailinfolayout.addView(focoulayout);
        focoulayout.setOrientation(LinearLayout.VERTICAL);
        //focoulayout.setBackgroundColor(XColor.RED);
        focoulayout.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
        new XPxArea(focoulayout).set(padding*2,0,screenW*0.24,XPxArea.MATCH);

        focoulayout.addView(focousnum);
        focousnum.setText("200");
        new XPxArea(focousnum).set(0,0,XPxArea.WRAP,XPxArea.WRAP);
        new TextViewTools(focousnum).textColor(XColor.WHITE);

        focoulayout.addView(focousText);
        focousText.setText("关注");
        new XPxArea(focousText).set(0,0,XPxArea.WRAP,XPxArea.WRAP);
        new TextViewTools(focousText).textColor(XColor.WHITE);

        listlayout.addView(mytipsTextview);
        mytipsTextview.setText("我的关注");
        mytipsTextview.setClickable(true);
        mytipsTextview.setPadding(0,padding/2,0,padding/2);
        mytipsTextview.setGravity(Gravity.CENTER_HORIZONTAL);
        new TextViewTools(mytipsTextview).textColor(XColor.WHITE).sizePx(FontSize.s18(context));
        new XPxArea(mytipsTextview).set(0,screenW*0.07,XPxArea.MATCH,XPxArea.WRAP);

        listlayout.addView(sportmonitorTextView);
        sportmonitorTextView.setText("运动监测");
        sportmonitorTextView.setPadding(0,padding/2,0,padding/2);
        sportmonitorTextView.setGravity(Gravity.CENTER_HORIZONTAL);
        new TextViewTools(sportmonitorTextView).textColor(XColor.WHITE).sizePx(FontSize.s18(context));
        new XPxArea(sportmonitorTextView).set(0,padding,XPxArea.MATCH,XPxArea.WRAP);

        listlayout.addView(userifoTextView );
        userifoTextView .setText("用户信息");
        userifoTextView .setPadding(0,padding/2,0,padding/2);
        userifoTextView .setGravity(Gravity.CENTER_HORIZONTAL);
        new TextViewTools(userifoTextView ).textColor(XColor.WHITE).sizePx(FontSize.s18(context));
        new XPxArea(userifoTextView ).set(0,padding,XPxArea.MATCH,XPxArea.WRAP);

        listlayout.addView(securitycenterTextView);
        securitycenterTextView.setText("安全中心");
        securitycenterTextView.setPadding(0,padding/2,0,padding/2);
        securitycenterTextView.setGravity(Gravity.CENTER_HORIZONTAL);
        new TextViewTools(securitycenterTextView).textColor(XColor.WHITE).sizePx(FontSize.s18(context));
        new XPxArea(securitycenterTextView).set(0,padding,XPxArea.MATCH,XPxArea.WRAP);








    }
}
